{include file="public_head" /}

<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>会员卡管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <div class="printArea">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm" >
                                    <script>
                                        $('#status_1').click(function(){
                                            $('#in').html('');
                                        });
                                        $('#status_2').click(function(){
                                            $('#in').html('<div class="form-group">\n' +
                                                '                                            <label class="control-label col-md-3 col-sm-3 col-xs-12">使用次数：</label>\n' +
                                                '                                            <div class="col-md-2 col-sm-6 col-xs-12">\n' +
                                                '                                                <input type="text" placeholder="请输入使用次数"\n' +
                                                '                                                       class="form-control col-md-7 col-xs-12" name="count"\n' +
                                                '                                                       value="{$item.count|default=\'\'}"\n' +
                                                '                                                       datatype="*"\n' +
                                                '                                                       nullmsg="请输入月卡次数！" errormsg="请输入使用次数"\n' +
                                                '                                                >\n' +
                                                '                                            </div>\n' +
                                                '                                        </div>');
                                        });
                                    </script>
                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">指派人：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<select name="shop_assignor_id[]" class="select2_multiple form-control"-->
                                                    <!--multiple="multiple"-->
                                                    <!--style="width: 500px;" tabindex="-1"-->
                                                    <!--datatype="*"-->
                                                    <!--nullmsg="请选择指派人！" errormsg="请选择指派人！"-->
                                            <!--&gt;-->
                                                <!--<option value="0"-->
                                                <!--&gt;-->
                                                    <!--请选择指派人-->
                                                <!--</option>-->
                                                <!--{volist name=":db('member')->select()" id="list"}-->
                                                <!--<option-->

                                                        <!--{in name='list.id' value='$item.shop_assignor_id|default=""'}selected{/in}-->
                                                <!--value="{$list.id}"-->
                                                <!--&gt;-->

                                                <!--{$list.username}-->
                                                <!--</option>-->
                                                <!--{/volist}-->

                                            <!--</select>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">指定会员：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <select name="member_id" class="select2_singlem" onchange="oc(this.value)"
                                                    style="width:100%;" tabindex="-1"
                                            datatype="*"
                                            nullmsg="请选择会员！" errormsg="请选择会员！"
                                            >
                                                <option value="">请选择会员</option>
                                            {foreach $member_list as $key=>$vo }
                                            <option value="{$vo.id}-{$vo.car_number}" {eq name='$item.member_id|default=""' value='$vo.id' }selected{/eq}>{$vo.username}
                                                -{$vo.car_number}
                                                </option>
                                            {/foreach}
                                            {/volist}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">发放门店：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            {eq name=":session('auding_status')" value="2"}
                                            <select name="shop_id" class="select2_singles"
                                                    style="width:100%;" tabindex="-1"
                                                    datatype="*"
                                                    nullmsg="请选择所在城市！" errormsg="请选择所在城市！"
                                            >
                                                {foreach :model('shop')->where('auding_status',2)->where('is_delete',1)->select() as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>{$vo.shop_title}</option>
                                                {/foreach}
                                                {/volist}
                                            </select>
                                            {else/}
                                            <select name="shop_id" class="select2_single"
                                                    style="width:100%;" tabindex="-1"
                                                    datatype="*"
                                                    nullmsg="请选择所在城市！" errormsg="请选择所在城市！"
                                            >
                                                {foreach :model('shop')->where('auding_status',2)->where('is_delete',1)->where('id',session('shop_id'))->select() as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>{$vo.shop_title}</option>
                                                {/foreach}
                                                {/volist}
                                            </select>
                                            {/eq}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">会员卡列表：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select name="system_card_id" class="select2_singlec" onchange="car(this.value)" style="width:100%;" tabindex="-1" datatype="*" nullmsg="请选择会员卡！" errormsg="请选择会员卡！">
                                                <option value="">请选择会员卡</option>
                                                {foreach $SystemCard as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>{switch name="$vo.type"}{case 1}年卡{/case}{case 2}次卡({$vo.count}){/case}{/switch}-价钱:{$vo.sale_price}-{$vo.title}-有效期 : {$vo.day}天</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>


                                    {in name=":session('manage_id')" value="$manage_array"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="text-align: right">是否免费：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <label class="radio_box">
                                                <input type="radio" name="order_is_free" id="status_1" class="cartradio"
                                                       value="6"
                                                       datatype="*"
                                                       nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                >&nbsp;&nbsp;
                                                <label for="status_1"></label>
                                                <span>是</span>
                                                &nbsp;&nbsp;
                                            </label>
                                            <label class="radio_box">
                                                <input type="radio" name="order_is_free" id="status_2" class="cartradio"
                                                       value="1"
                                                       datatype="*"
                                                       nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                       checked
                                                >&nbsp;&nbsp;
                                                <label for="status_2"></label>
                                                <span>否</span>
                                                &nbsp;&nbsp;
                                            </label>
                                        </div>
                                    </div>
                                    {/in}


                                    <div id="in">

                                    </div>
                                    <div id="in_car_number">

                                    </div>


                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">派发数量：</label>-->
                                        <!--<div class="col-md-2 col-sm-6 col-xs-12">-->
                                            <!--<input type="text" placeholder="请填写派发数量"-->
                                                   <!--class="form-control col-md-7 col-xs-12" name="number"-->
                                                   <!--value="{$item.number|default=''}"-->
                                                   <!--datatype="int" id="num"-->
                                                   <!--nullmsg="请填写派发数量！" errormsg="请填写派发数量大于1的数字！"-->
                                            <!--&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->


                                </div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {present name="$item.id"}
                                            <input type="hidden" name="id" value="{$item.id}">
                                            {/present}
                                            <!--<input type="hidden" name="member_id" value="0"/>-->
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                            <button type="button"  class="btn btn-danger" id="btnPrint">打印文本区域</button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<script>
    function ef(){
       var num = $("#num").val();

       if(num <= 1){

           layer.msg("派发数量必须大于1");
           return false;
       }

    }

    function oc(v){ //切换会员
        $.ajax({
            url : '{:url("member/ajax")}',
            data:{'id':v},
            dataType:'json',
            success:function(data){
               if(data.is_certification != 2){ //未认证
                   var input_status = '';
                   if(data.car_number != ''){
                       input_status = 'readonly';
                   }
                var str = '<div class="form-group">\n' +
                    '                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">车牌号：</label>\n' +
                    '                                        <div class="col-md-2 col-sm-6 col-xs-12">\n' +
                    '                                            <input type="text" placeholder=""\n' +
                    '                                                   class="form-control col-md-7 col-xs-12" name="car_number" value="'+data.car_number+'" '+input_status+' aria-placeholder="车牌号" style="max-width:100%" />\n' +
                    '                                        </div>\n' +
                    '                                    </div>';
                    $('#in_car_number').html(str);
               }else{
                   $('#in_car_number').html('');
               }
            }
        });
    }

    function car(v){ //切换会员卡
        $.ajax({
            url : '{:url("SystemCard/type")}',
            data:{'id':v},
            dataType:'json',
            success:function(data){
               if(data == 1){ //年卡
                    oc($('[name="member_id"]').val());
               }else{
                   $('#in_car_number').html('');
               }
            }
        });
    }
    // validform
    $(function () {
        $(".select2_single").select2({
            placeholder: "",
            allowClear: true
        });
        $(".select2_singlec").select2({
            placeholder: "请选择会员卡",
            allowClear: true
        });
        $(".select2_singles").select2({
            placeholder: "请选择门店",
            allowClear: true
        });
        $(".select2_singlem").select2({
            placeholder: "请选择会员",
            allowClear: true
        });

        $.Tipmsg.r = null;
        $.Datatype.int = /^[1-9]\d*$/;
        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true,

        });

        // interval_timer
        $('#interval_timer').daterangepicker(null,
                function(start, end, label) {
                    console.log(start.toISOString(), end.toISOString(), label);
                });

        // select2
        $(".select2_multiple").select2({
            maximumSelectionLength: 0,
            placeholder: "请选择关联栏目",
            allowClear: true
        });
    })
</script>
<script src="/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
<script>
    $('#status_2').click(function () {

        $('#service_people').hide();

    });
    $('#status_1').click(function () {

        $('#service_people').show();

    });
    $("#btnPrint").click(function(){
        $(".printArea").printArea();
    });
    $("#btnPrintFull").click(function(){
        $("body").printArea();
    });

</script>

</body>

</html>
